package com.bruce.framework.result;

import com.bruce.framework.IResponse;
import com.bruce.framework.json.BaseJsonUtil;

import java.util.Objects;

/**
 * 执行结果
 * <br>CreateDate  2021/09/09 10:50:57
 *
 * @author luotuan
 * @version 1.0.0
 */
public class ExecuteResult implements IResponse {
    private static final long serialVersionUID = 860257070220783294L;

    /**
     * 操作是否成功
     */
    private Boolean successful = new Boolean(true);

    /**
     * 响应信息
     */
    private ResponseInfo responseInfo;
    @Override
    public Boolean isSuccessful() {
        return successful;
    }

    @Override
    public ResponseInfo getResponseInfo() {
        return responseInfo;
    }

    @Override
    public String toJson() {
        return BaseJsonUtil.toJson(this);
    }

    @Override
    public void cloneResponseInfo(IResponse source) {
        if(Objects.isNull(source) || Objects.isNull(source.getResponseInfo())){
            return;
        }
        setResponseInfo(source.getResponseInfo());
    }

    public Boolean getSuccessful() {
        return successful;
    }

    public void setSuccessful(Boolean successful) {
        this.successful = successful;
    }

    public void setResponseInfo(ResponseInfo responseInfo) {
        this.responseInfo = responseInfo;
    }
}
